package com.company.pddpre;

import java.util.Scanner;

public class Main1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] point = new int[N];
        for(int i = 0;i < N;i++){
            point[i] = sc.nextInt();
        }

        // 距离为0
        if(K == 0){
            System.out.println("paradox");
        }

        // 距离不为0
        // 距离
        int finalPosition = K;
        // 返回次数
        int backCount = 0;

        for(int i = 0;i < point.length;i++){
            if(finalPosition - point[i] > 0){
                finalPosition -= point[i];
            }else if(finalPosition - point[i] == 0){
                finalPosition -= point[i];
                break;
            }else{
                finalPosition = Math.abs(finalPosition - point[i]);
                backCount++;
            }
        }
        if(finalPosition == 0){
            System.out.println("paradox");
        }else{
            System.out.println(finalPosition + " " + backCount);
        }
    }
}
